package com.cmbchina.ccd;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.cmbchina.ccd.db.entity.ReportActivity;
import com.cmbchina.ccd.db.entity.ReportActivityWords;
import com.cmbchina.ccd.db.service.ReportActivityService;
import com.cmbchina.ccd.db.service.ReportActivityWordsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Component
public class ReportApplicationRunnner implements ApplicationRunner {

    public Map<String, String> map = new HashMap<>();

    public Map<String, String> activities = new HashMap<>();

    @Autowired
    private ReportActivityWordsService reportActivityWordsService;

    @Autowired
    ReportActivityService reportActivityService;

    @Override
    public void run(ApplicationArguments args) throws Exception {
        List<ReportActivityWords> reportActivityWords = reportActivityWordsService.selectList(new EntityWrapper<>());
        for(ReportActivityWords reportActivityWord : reportActivityWords) {
            map.put(reportActivityWord.getWord(), reportActivityWord.getActivityId());
        }

        List<ReportActivity> reportActivities = reportActivityService.selectList(new EntityWrapper<>());
        for(ReportActivity reportActivity : reportActivities) {
            activities.put(""+reportActivity.getId(), reportActivity.getActivityName());
        }
    }
}
